﻿Imports System
Imports System.Collections.Generic
Imports System.Reflection
Imports System.Workflow.ComponentModel.Serialization
Imports System.Xml

Namespace System.Workflow.ComponentModel.Design
    Public Class FreeformActivityDesignerLayoutSerializer
        Inherits CompositeActivityDesignerLayoutSerializer
        ' Methods
        Protected Friend Overrides Function GetProperties(ByVal serializationManager As WorkflowMarkupSerializationManager, ByVal obj As Object) As PropertyInfo()
            If (serializationManager Is Nothing) Then
                Throw New ArgumentNullException("serializationManager")
            End If
            If (obj Is Nothing) Then
                Throw New ArgumentNullException("obj")
            End If
            Dim writer As XmlWriter = [TryCast](serializationManager.WorkflowMarkupStack.Item(GetType(XmlWriter)),XmlWriter)
            Dim properties As PropertyInfo() = MyBase.GetProperties(serializationManager, obj)
            Dim designer As FreeformActivityDesigner = [TryCast](obj,FreeformActivityDesigner)
            If (designer Is Nothing) Then
                Return properties
            End If
            Dim list As New List([Of] PropertyInfo)
            Dim info As PropertyInfo
            For Each info In properties
                If (((writer Is Nothing) OrElse Not info.Name.Equals("AutoSizeMargin", StringComparison.Ordinal)) OrElse (designer.AutoSizeMargin <> FreeformActivityDesigner.DefaultAutoSizeMargin)) Then
                    list.Add(info)
                End If
            Next
            list.Add(GetType(FreeformActivityDesigner).GetProperty("DesignerConnectors", (BindingFlags.NonPublic Or BindingFlags.Instance)))
            Return list.ToArray
        End Function

    End Class
End Namespace

